//
//  UMPListener.h
//  UMPDemo
//
//  Created by Jonathan Diehl on 13.01.09.
//  Copyright 2009 Media Computing Group. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <ftdi.h>
#import "ump.h"

@class UMPListener;
@protocol UMPListenerDelegate
- (void)umpListener:(UMPListener *)listener didReceiveTouches:(NSArray *)touches;
- (void)umpListenerDidFail:(NSError *)error;
@optional
- (void)umpListenerDidUpdate:(UMPListener *)listener;
@end


@interface UMPListener : NSObject {
	struct ftdi_context ftdic;
	ump_context umpc;
	
	NSObject<UMPListenerDelegate> *delegate;
	BOOL delegateWantsUpdates;

	NSThread *listeningThread;
	BOOL listening;
	
	NSDictionary *properties;
	
	NSArray *touches;
}

@property(assign) NSObject<UMPListenerDelegate> *delegate;
@property(readonly) ump_context umpc;

// init
- (id)initWithDelegate:(NSObject<UMPListenerDelegate> *)aDelegate startImmediately:(BOOL)start error:(NSError **)error;

// port listening
- (BOOL)start:(NSError **)error;
- (BOOL)stop:(NSError **)error;

@end
